home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-11-04 | 54.2 KB | 1,470 lines |
- Newsgroups: comp.sources.misc
- From: alan@tharr.UUCP (Alan Saunders)
- Subject: v25i022: QBATCH - a queued batch processing system for UNIX, Part03/06
- Message-ID: <1991Nov5.034753.5007@sparky.imd.sterling.com>
- X-Md4-Signature: 038344f1eff902afe3c6ae66e19fc871
- Date: Tue, 5 Nov 1991 03:47:53 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: alan@tharr.UUCP (Alan Saunders)
- Posting-number: Volume 25, Issue 22
- Archive-name: QBATCH/part03
- Environment: UNIX
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 3 (of 6)."
- # Contents: DESCRIPTION INSTALL doc/chap.02 doc/chap.07 doc/chap.08
- # doc/chap.09 man/qbatch.l src/Makefile src/qc.c src/ql.c
- # Wrapped by root@vfib_d on Thu Oct 31 15:46:39 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'DESCRIPTION' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'DESCRIPTION'\"
- else
- echo shar: Extracting \"'DESCRIPTION'\" \(5580 characters\)
- sed "s/^X//" >'DESCRIPTION' <<'END_OF_FILE'
- X
- X The QBATCH system and its related programs were
- X written by Alan D. Saunders and are
- X Copyright (c) Vita Services Ltd. 1990 and
- X Copyright (c) Vita Fibres Ltd. 1991
- X
- X PLEASE read the NOTICE file for details.
- X
- QBATCH is a versatile queued batch processing system for *NIX.
- X
- XEach queue consists of a file containing information about the queue
- itself, and about all jobs currently present in the queue. When the
- program 'qp' is run for a given queue, it will fork a child process for
- each job in the queue in turn, and wait for it to complete. If there
- are no jobs present in the queue, qp will wait for a signal from one of
- the support programs, which will 'tell' it that another job has joined
- the queue, or that it should terminate.
- X
- XFeatures:
- X
- There can be as many queues as the system can support. Queues are
- named, and run asynchronously. The processing of jobs running in one
- queue are totally independent of those in any other (subject of course
- to the independence of potentially shared resources such as data files
- and devices).
- X
- Queues can be started and stopped independently. If a job is running
- in a queue which receives a stop signal from the 'qs' program (NOT
- SIGSTOP) qp will allow the job to run to completion before terminating
- unless the kill option is specified.
- X
- The priority (nice value) of all jobs running in a queue is defined
- when the queue is created, so prioritised queues can be configured.
- X
- Jobs running in a queue consist of shell scripts, created (or copied)
- by the js program. The default shell is the bourne shell, but this can
- be overridden at submit time with the -s option to js. The jobs run
- with the uid and gid of the submittor, and run in the environment
- ruling when the job was submitted. All environment variables except
- those excluded deliberately are passed to the job, and the job will
- start in the submittors current working directory. Fixed context
- queues may be configured which overrule the above, they may be
- configured to run under a specified default shell, with a specified
- uid and gid (NOT root), and with a pre-defined environment and working
- directory. Access to fixed context queues may be restricted by user-
- name and group.
- X
- Stdout and stderr of running jobs is redirected to a 'monitor' This
- will normally be the queue monitor (specified or defaulted when the
- queue was created), but may be specified for individual jobs. The
- pathspec of both the job file, and the monitor, may be accessed with
- the 'qf' program viz: "tail -f `qf -m work`" where 'work' is the name
- of a queue.
- X
- The status and contents of queues can be listed at any time using the
- X'ql' program. Information can include the uid and gid under which jobs
- will run (are running), user name and tty of submittor, date and time
- of submission, date and time current job started, and a meaningful job
- name or description.
- X
- If rc.QBATCH is configured in the system init script, all queues which
- were running when the system went down will be restarted. Any jobs
- present in the queues will also be restarted.
- X
- XFacilities:
- X
- inform user by mail, or tty message when job is complete.
- cancel jobs in queues, or kill running jobs.
- change the running order of jobs in queues.
- suspend and resume processing of jobs.
- start and stop the queue process engine at any time (even under cron or from
- X another queue)
- disable submissions to a queue, and re-enable them.
- stop a queue, and wait until the current job has finished (useful for ensuring
- X that the system is idle before a backup)
- list the status and contents of a queue.
- repeat (or kill and repeat) the currently running job in a queue.
- examine or edit the jcl of jobs in a queue, and examine the monitors.
- monitor (and perhaps account) the times taken by jobs in the queue.
- X
- Prevent deadlocks between batch programs accessing the same devices or data
- files by ensuring they are submitted to the same queue, then they can't run in
- parallel.
- X
- Prevent cpu hogging jobs from swamping the system by submitting them to
- low-priority queues.
- X
- Have a separate queue for humungous jobs that is started and stopped by cron
- out of working hours.
- X
- XEnsure all overnight work is running in queues, then a backup job can stop the
- queues, wait for current jobs to finish, and back up before restarting the
- queues.
- X
- Protect sensitive applications and data with file and directory permissions,
- then permit named users or groups to submit jobs to a fixed context queue.
- X
- Queues can only be created by root, so the system administrator can tune the
- configuration to provide optimum throughput. It is frequently the case,
- particularly if a system is swapping heavily, or is short of swap space, that
- two jobs running one after the other in a queue, will process faster overall
- than if they were run concurrently.
- X
- Of course, porting and installing QBATCH isn't the end. Queue discipline has to
- be imposed in order for it to be of any benefit. Scripts and commands
- triggering batch jobs will have to be changed to use QBATCH, and jobs normally
- run interactively which impose heavy system loads, will have to be
- reconfigured. (consider for example renaming 'make' as 'MAKE' and writing a
- X'make' script which submits 'MAKE' to a queue). Of course there will always be
- the awkward user who decides to submit a large job into a high priority queue.
- Analysing the queue monitors should show this up, they contain a certain amount
- of profile timing for jobs run in the queue, and the uid and gid of the submittor.
- X
- This should give you a taste of what QBATCH has to offer.
- X
- Regards .. Alan
- X
- END_OF_FILE
- if test 5580 -ne `wc -c <'DESCRIPTION'`; then
- echo shar: \"'DESCRIPTION'\" unpacked with wrong size!
- fi
- # end of 'DESCRIPTION'
- fi
- if test -f 'INSTALL' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'INSTALL'\"
- else
- echo shar: Extracting \"'INSTALL'\" \(4889 characters\)
- sed "s/^X//" >'INSTALL' <<'END_OF_FILE'
- X
- X QBATCH Version 2.0 Installation notes and bewares
- X
- X The QBATCH system and its related programs were
- X written by Alan D. Saunders and are
- X Copyright (c) Vita Services Ltd. 1990 and
- X Copyright (c) Vita Fibres Ltd. 1991
- X
- X PLEASE read the NOTICE file for details.
- X
- XFIRST READ ALL OF THE TEXT FILES IN THIS DIRECTORY!!! Then read those in the
- X'doc' directory. Then you will know what QBATCH is, and the conditions you
- are deemed to have accepted by compiling, installing, and using it.
- X
- XEspecially read the file doc/chap.09 (security). Some of the concepts outlined
- here may be overruled by it's contents.
- X
- Once you are satisfied, change directory to the src directory, and have
- a look at config.h. You should find configuration options available
- which are supported by your system. If not, there should be enough
- information contained therein to allow you to add further options if
- you both feel it necessary, and are capable. Define the configuration
- for your platform by commenting out those options which are not
- supported, and uncommenting those (one in each group) which are.
- X
- Then look at the Makefile, and ensure that BINDIR is set to where you
- want the binaries installed, and that MANDIR is where you want the
- manual pages. Also check to see if the defined paths for SPOOLPATH
- and QUEUEPATH are satisfactory for your system. QUEUEPATH is where the
- actual queue files themselves go. The directory must exist. It must be
- world searchable, but should only be root writeable. SPOOLPATH is
- where the batch files are created, again, the world should be able to
- look at the contents of these files (jcl and monitors), but only root
- should be able to create and delete them.
- X
- Now, if you are not your systems administrator, you are at his (or her)
- mercy. Certain of the QBATCH programs need to be able to set user and
- group id's so they must be owned by root, and setuid. The Makefile
- assumes that the person running make, is actually root, and changes
- file modes accordingly. Some of the programs simply will not work
- properly if they don't have the right modes and/or are not owned by
- root.
- X
- Try 'make' and see if there are any errors. If you can resolve them,
- do so, BUT LET ME KNOW!!, I will include fixes, and or release patches
- as needed.
- X
- If you get a clean compilation, but are not logged in as root, remove
- the executables, and call your sysadmin to re-make as root.
- X
- Make the directories defined in QBATCH.h as SPOOLPATH and QUEUEPATH, and
- ensure they have the correct permissions.
- X
- If there are environment variables defined for users which are
- meaningless in a batch context (or harmful) create a file '.qxenv' in
- QUEUEPATH containing a list (one per line) of those environment
- variables to be EXCLUDED from batch jobs. Ensure it is readable
- X(only) by root.
- X
- If you are going to implement fixed context queues, create a file in
- QUEUEPATH called '.<queuename>rc' setting up the context and environment
- for the jobs, for each queue created using the -f option of qc. (see
- the man page for qc).
- X
- Then make install, create some queues, and try it out.
- X
- BEWAREs
- X
- QBATCH is only as good as the scripts it is running. It has been
- running now for a year on several sparcstations and servers, and the
- only problems we have encountered have been on file permissions, where
- files have been created in the foreground in a setuid script(??), and
- the batch job has tried to delete those files
- X.... The batch job unless running in a fixed context queue with #QCONTEXT
- specified in the .<queuename>rc file, runs under the user's real uid!
- In these cases, the script hangs until someone types something on the
- system console.
- X
- Job control. I am aware that some systems do not support this (alright
- call me a liar!) Job control is only used in QBATCH, to group together
- any children which may be forked by a running job. This is so that a
- signal (SIGSTOP, SIGCONT, and SIGKILL) sent to the pid of a running
- job, is actually propagated through it's children. Unless you can find
- a way round this, if you need to do such a thing, you'll have to
- examine the 'ps' output to identify the children if any, and kill them
- by hand. (the job itself of course will receive the original signal).
- X
- truncate(), ftruncate(). Some systems don't support this either. It
- won't do any damage to QBATCH to leave it out, it's only there for
- tidiness' sake. The queue files will grow as jobs are added, and
- shrink as they are processed or canceled. Truncate is used to ensure
- that unused trailing space in a queue file is returned to the system.
- If you don't have it, and can't emulate it, You'll have to live with
- it. If it becomes a problem, you'll have to periodically tidy up
- manually.
- X
- XEnjoy ... Alan Saunders August 30 1991
- X
- If you do come across any problems, with security or anything else
- relating to QBATCH, please contact me, as I hope you will if you design
- any enhancements or bug fixes.
- END_OF_FILE
- if test 4889 -ne `wc -c <'INSTALL'`; then
- echo shar: \"'INSTALL'\" unpacked with wrong size!
- fi
- # end of 'INSTALL'
- fi
- if test -f 'doc/chap.02' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/chap.02'\"
- else
- echo shar: Extracting \"'doc/chap.02'\" \(4776 characters\)
- sed "s/^X//" >'doc/chap.02' <<'END_OF_FILE'
- X QBATCH .. a queued batch processing system for UNIX
- X
- X
- X The QBATCH system and its related programs were
- X written by Alan D. Saunders and are
- X Copyright (c) Vita Services Ltd. 1990 and
- X Copyright (c) Vita Fibres Ltd. 1991
- X
- X2. DESCRIPTION.
- X
- X A QBATCH queue is a file containing information relating to the queue
- X itself, and to the jobs queued for processing therein. The location of the
- X queue is defined by the implementor, and compiled into the QBATCH programs.
- X A queue is created using the qc program, which creates such a file in the
- X defined location, and unless overridden by command line options, stores the
- X default spooling path (where job files are created), monitor (where stdout
- X and stderr are redirected), and nice value. Any of these parameters may be
- X overridden at queue creation time, or altered at any time, by using the
- X same qc program (qv.). The fixed context flag may also be set or altered
- X in the same way.
- X
- X The QBATCH queue process engine is the program qp. For any active queue,
- X qp runs in the background waiting for a signal from one of the support
- X programs. When such a signal is received, qp checks the contents of the
- X queue and acts accordingly. If a new job has been submitted to the queue
- X (and one is not currently running), qp will fork a child process to handle
- X it, then wait for the child to complete. The child will setuid to the
- X owner of the job, and setgid to the owners group. It will then attach
- X stdout and stderr to the job's monitor, renice to the queue priority, and
- X execute the job. When the job has finished, qp is woken by a SIGCHLD. qp
- X will then tidy up the queue, remove the job file, and if required, notify
- X the job owner.
- X
- X The action of qp in response to a signal is governed by a set of flags in
- X the queue header. These 'action' flags are:
- X
- X repeat. If set, the currently running job will not be removed from the
- X queue when it terminates or is killed, nor will it's job file be
- X removed. Instead, it will remain in the queue effectively as the
- X next job to be processed.
- X
- X kill. If set, qp will send a SIGKILL to the currently running job, to
- X terminate it immediately.
- X
- X halt. This flag is a toggle. If it has changed from unset to set, qp
- X will send a SIGHALT to the currently running job, to suspend it's
- X processing. If it has changed from set to unset, qp will send a
- X SIGCONT to the job, to resume it's processing. If it is unchanged,
- X no action will be taken.
- X
- X stop. If set, when the current job (if any) terminates or is killed, qp
- X itself will terminate. If no job is running qp will terminate
- X immediately.
- X
- X If none of the above flags are set (or in the case of halt, toggled), then
- X qp will check the count of jobs in the queue. If further jobs are present,
- X the next will be processed, otherwise qp will wait for another signal.
- X
- X Programs which alter the settings of these flags are:
- X
- X qs (queue stop) Sets the stop, and optionally the kill and or
- X repeat flags.
- X jk (job kill (remove)) May set the kill flag.
- X jr (job repeat) Sets the repeat, and optionally the kill flag.
- X qh (queue halt) Sets the halt flag if not already set.
- X qg (queue go) Clears the halt flag if set.
- X
- X There are two further flags stored in the queue header, both used by the js
- X program:
- X
- X fixed. This indicates a fixed context queue. This concept will be
- X discussed later.
- X
- X enabled.This flag determines whether the job submit program will submit jobs
- X to the queue. If unset, js will not submit jobs.
- X
- X The enabled flag is set by qe, and unset by qd.
- X
- X Jobs may be submitted to any permitted queue through the program js. By
- X default, any user can submit jobs to any queue. Restriction of access is
- X only available in fixed context queues (see later). A queue which has it's
- X enabled flag unset is disabled, and js will not submit a job to such a
- X queue for any user.
- X
- X Jobs may be removed from a queue by the job owner or by the super user
- X using the jk program. If processing has already started, jk will refuse to
- X remove the job unless the -k (kill running job) option is specified.
- X
- X The position of jobs in a queue may be altered by the owner or super user
- X with the jj program. Controls prevent any user from jumping the queue by
- X permitting only the super user to jump jobs to positions held by jobs owned
- X by other users.
- X
- X Listing the contents of a named queue is achieved with the ql program, and
- X a list of queues available to a user is provided by qa. Various
- X information is provided by qf and qt.
- END_OF_FILE
- if test 4776 -ne `wc -c <'doc/chap.02'`; then
- echo shar: \"'doc/chap.02'\" unpacked with wrong size!
- fi
- # end of 'doc/chap.02'
- fi
- if test -f 'doc/chap.07' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/chap.07'\"
- else
- echo shar: Extracting \"'doc/chap.07'\" \(4825 characters\)
- sed "s/^X//" >'doc/chap.07' <<'END_OF_FILE'
- X
- X QBATCH .. a queued batch processing system for UNIX
- X
- X
- X The QBATCH system and its related programs were
- X written by Alan D. Saunders and are
- X Copyright (c) Vita Services Ltd. 1990 and
- X Copyright (c) Vita Fibres Ltd. 1991
- X
- X7. TUNING.
- X
- X What is tuning? I consider tuning, of a program, an application, or a
- X system, to be an exercise consisting of modifying those parameters in the
- X operation which may be modified, with the aim of optimising throughput.
- X
- X How do you define optimum throughput? My definition is:
- X "optimum throughput is when both the load on system resources, and the
- X complaints of users are at a minimum".
- X
- X How do we achieve this?
- X
- X a. By restraining large resource hungry jobs to a small number of low
- X priority queues. This frees up resources for other users, and other
- X jobs, and reduces the complainers to those thus restricted.
- X
- X b. By ensuring that users don't lose out by using the queued batch system
- X instead of 'batch', or simply dumping the job into the background with
- X '&'. This means providing a reasonable number of normal and high
- X priority queues, and ensuring that the jobs go into the correct queues.
- X This may mean creating submission scripts for some jobs, in other cases
- X it may be just (?? &-)) a case of user training.
- X If you have a situation where a large user base can be defined as a
- X series of discrete 'teams' or workgroups, consider assigning queues on
- X a workgroup basis. Contention between users over job priority is
- X easier to resolve under these conditions, and complaints will be fewer.
- X
- X c. By monitoring the profile timings of jobs through each queue. The times
- X taken are reported in the monitor for each job processed. They are
- X also accumulated in the queue header. A summary of timings may be
- X displayed at any time with:
- X qf -s <queuename>
- X A typical display would be:
- X
- X
- X Queue started : Wed Oct 2 15:02:37 1991
- X
- X Available for : 5 Min 14.00 Sec
- X No. Jobs Processed: 10
- X
- X Times: Actual Av. Per Job
- X
- X Queued 5:45.00 Sec 34.50 Sec
- X Real 1:43.68 Sec 10.36 Sec
- X User 0.60 Sec 0.06 Sec
- X System 2.69 Sec 0.26 Sec
- X
- X Utilisation (real/available) 33.01%
- X
- X Current job not accounted for above, running for : 7.00 Sec
- X
- X (not actually typical, this is from my development system, not a live
- X system).
- X
- X The figures are:
- X Queued: The time a job was on the queue before starting to process.
- X Real: The actual (wall clock) time from start to end of processing.
- X User: The user cpu time taken by the job.
- X System: The system cpu time taken by the job.
- X
- X Ideally, if a system is correctly tuned, the average timings of a given
- X queue should only vary within limits. Any wider variance is a reason to
- X look at the individual times in the monitors.
- X
- X Consistently low utilisation would probably indicate that jobs
- X submitted to this queue could probably share resources better by being
- X submitted to another low utilisation queue, and removing this one.
- X Conversely, consistently high utilisation could mean that too many jobs
- X are being submitted to this queue, and the load might be better split.
- X
- X As discussed in the chapter on configuration, queues should be configured
- X initially on the basis of resource requirement. Jobs requiring the same
- X (potentially limited) resources should be submitted to the same queue, so
- X that there are no additional scheduling overheads imposed on the kernel for
- X these jobs. This may well be a case of trial and error, it may not be
- X possible to predict what resources are demanded by a test job submitted by
- X a programmer on a new project. This really indicates that QBATCH use, once
- X implemented in a system, should be designed into new systems by the
- X programmers themselves, who would then (hopefully), design the programs,
- X and supporting scripts with system policy, and resource availability in
- X mind.
- X
- X In short, there is no short answer to tuning. QBATCH can provide the tools
- X for better utilisation of resources, but to be effective, It needs to be
- X implemented throughout a system, with no back doors through which users can
- X 'steal' resources. It will take monitoring over a period of time, closing
- X loopholes, and warning users who do not comply. It will take creation of
- X new queues at different priorities to share the workload equitably. It will
- X take swapping jobs from queue to queue until the balance is right. It will
- X take WORK! (I know .. it's a dirty word.) You will know when you have got
- X it right when the 'phone stops ringing.
- END_OF_FILE
- if test 4825 -ne `wc -c <'doc/chap.07'`; then
- echo shar: \"'doc/chap.07'\" unpacked with wrong size!
- fi
- # end of 'doc/chap.07'
- fi
- if test -f 'doc/chap.08' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/chap.08'\"
- else
- echo shar: Extracting \"'doc/chap.08'\" \(4681 characters\)
- sed "s/^X//" >'doc/chap.08' <<'END_OF_FILE'
- X
- X QBATCH a queued batch processing system for UNIX
- X
- X
- X The QBATCH system and its related programs were
- X written by Alan D. Saunders and are
- X Copyright (c) Vita Services Ltd. 1990 and
- X Copyright (c) Vita Fibres Ltd. 1991
- X
- X8.FIXED context queues.
- X
- X A fixed context queue is one where the 'environment' of a job running
- X in it is fixed. A control file, located in the same directory as the
- X queue itself, contains directives, and perhaps initial jcl which will
- X set up and fix the running environment of all jobs processed in the
- X queue. This control file (.<queuename>rc in QUEUEPATH) may also be
- X used to restrict access to the queue.
- X
- X Fixed context queues were designed for those occasions when a job must
- X run, but where the environment, (PATH, CWD etc) is unpredictable,
- X non-existent, or must be fixed for a particular application. The
- X original tasks for which I designed this concept were jobs run
- X remotely via uux. Others which spring to mind are, complex
- X mailservers, and user add-ons to an externally supplied application.
- X
- X In it's simplest form, a job running in a fixed context queue does not
- X carry the environment variables present when the job was submitted,
- X but only those set up in the control file for that queue. The control
- X file may also contain jcl (such as changing directories, mounting
- X secure partitions) which will be run before the submitted jcl. It can
- X also be used to specify the shell under which the job will run instead
- X of /bin/sh.
- X
- X The shell can be specified by including a line
- X
- X #!<shellpathspec>
- X
- X as the FIRST line in the control file. This will overrule ANY other
- X specification of the shell to run under. (even the -s option to js will
- X be silently ignored). The reason for this is that any 'jcl' in the
- X control file, even that setting environment variables, is shell
- X specific. Syntax suitable for the bourne shell is not suitable for the
- X c-shell etc.
- X
- X Extensions to this simple case are created by the use of #Q directives
- X in the control file.
- X
- X Using them you can:
- X Have all jobs in this queue run under a particular uid and gid,
- X (#QCONTEXT)
- X NOTE A fixed context queue with a #QCONTEXT directive instructing the
- X jobs to run as root IS NOT PERMITTED!
- X
- X Limit access to this queue to a given list of users
- X (#QUSERS)
- X
- X limit access to this queue to a given list of groups
- X (#QGROUPS)
- X
- X Include selected environment variables into the environment of the job.
- X (#QGETENV)
- X
- X These facilities are available ONLY if the appropriate #Q directives
- X are present. Adequate security of the .<queuename>rc file will
- X prevent malicious inclusion of say #QCONTEXT directives.
- X
- X For details of the use and syntax of #Q directives, see the man page
- X for qc (queue create).
- X
- X Additionally, environment variables may be set for the job using
- X #ENV directives. These are normally generated by js, either for all the
- X environment in a normal queue, or for environment variables directed by
- X #QGETENV directives in a fixed context queue. The syntax is:
- X
- X #ENV <environment variable>=<value>
- X
- X e.g.
- X #ENV PATH=/usr/ucb:/usr/bin
- X
- X There should be one or more spaces or tabs after #ENV, and NOWHERE ELSE
- X (except in a quoted string).
- X
- X The #ENV directive is read by qp (the queue process engine) to set up
- X an environment table for the job independent of the shell under which
- X it will run.
- X
- X The #Q directives are read by js, both to handle queue restrictions,
- X and generate #ENV directives.
- X
- X The control file may also contain any 'jcl' or script code valid in the
- X shell under which the job is to run.
- X
- X It is possible, using fixed context queues to effectively turn almost
- X any program into a pseudo daemon. qp reads the jcl file submitted, and
- X creates an argument list based on the first line. It then adds the jcl
- X filespec as the last argument. It then reads through the jcl file,
- X setting up an environment table according to #ENV directives contained
- X in it. It then exec's the appropriate shell with the generated
- X argument and environment tables.
- X
- X The 'shell' specified does not have to be a bona fide shell. It can be
- X any program which can handle the syntax of the script submitted to it.
- X The only proviso is that it must ignore any lines beginning with '#'.
- END_OF_FILE
- if test 4681 -ne `wc -c <'doc/chap.08'`; then
- echo shar: \"'doc/chap.08'\" unpacked with wrong size!
- fi
- # end of 'doc/chap.08'
- fi
- if test -f 'doc/chap.09' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'doc/chap.09'\"
- else
- echo shar: Extracting \"'doc/chap.09'\" \(4524 characters\)
- sed "s/^X//" >'doc/chap.09' <<'END_OF_FILE'
- X
- X QBATCH
- X
- X The QBATCH system and its related programs were
- X written by Alan D. Saunders and are
- X Copyright (c) Vita Services Ltd. 1990 and
- X Copyright (c) Vita Fibres Ltd. 1991
- X
- X Because of the nature of QBATCH, some of the programs have to run setuid
- X as root. THIS IS A POTENTIAL SECURITY HOLE!! Unless you ensure that only
- X root can copy or write to them. Setuid programs are dangerous unless
- X properly protected. On systems (like SunOS) where linking is by default
- X dynamic (using shared libraries), it is highly recommended that the ld
- X switch forcing static linking be used for setuid programs (-Bstatic).
- X This aside, I am not aware of any security problems caused by QBATCH.
- X Systems administrators who are uncomfortable with the concept of fixed
- X context queues can satisfy themselves that if the programs and support
- X files are properly protected, they can enhance rather than degrade
- X security. NOTE a fixed context queue running as root is not permitted.
- X If they are still not satisfied, they can always disable the option by
- X removing the 'f' from the getopts statement in qc.c. The code is there
- X to be vetted if you are worried, there's nothing hidden, and I've nothing
- X to hide; satisfy yourself.
- X
- X Considerations: qp needs to be running in root context since it actually
- X has to setuid itself to the appropriate uid and gid when a job is
- X forked.
- X
- X qf, ql, and qw need read access ONLY to the queue files.
- X
- X jj, jm, jn, jr, qc, qd, qe, qh, qg, and qs need read and write access
- X ONLY to the queue files.
- X
- X js and jk need read and write access to both the queue files, and the jcl
- X files created.
- X
- X The user submitting the job (the job owner except in the case of a fixed
- X context queue) needs read access to the monitor files created, and may
- X need read, (and possibly write) access to the jcl files created.
- X
- X In the current implementation (I AM AWARE THAT THIS IS NOT IDEAL.. Any
- X ideas?), the queue files themselves are owned by root, with owner read
- X and write access, and world readable. All programs are owned by root.
- X
- X A. qf, qw, and ql are not setuid, and are owner only read and write, but
- X world executable.
- X
- X B. qc, qe, qd, qh, qg, qp, and qs are not setuid, and are owner only
- X read, write and execute. There is no world access, and they further check
- X that the user is root when they are run.
- X
- X C. jj, jk, jm, jn, jr, and js are setuid, are owner read and write, and
- X world executable.
- X
- X If a user (with a locked password) were created (say QBATCH), and all
- X queue files and programs were owned by this user, then:
- X
- X Group A would be unchanged.
- X
- X Group B would be unchanged except for qc, which would have to change the
- X ownership of the newly created queue.
- X
- X Group C would be unchanged except:
- X
- X js would STILL need to be setuid root since it needs both to write to the
- X queue file, and to create the jcl and change it's ownership.
- X
- X jk also would need to be setuid root since it needs both to write to the
- X queue file, and delete the jcl file.
- X
- X I am sure that the security from a system viewpoint could be improved. I
- X AM OPEN TO SUGGESTIONS!!
- X
- X The files that really need to be secure are:
- X
- X The queues themselves (lest someone patch the uid field)
- X The jcl files (should only be readable/writeable by the job
- X owner)
- X The .<qname>rc files (should only be readable by js)
- X The .qxenv file (ditto)
- X
- X I do not feel that the monitor files are a security risk, Any user needs
- X to be able to check the success or otherwise of jobs submitted by him.
- X If jobs are to be run where sensitive information is sent to stdout or
- X stderr, then the separate monitor (-m) option of js can be used.
- X
- X CAN YOU SEE ANY OTHER HOLES?
- X
- X Whilst I am aware of potential shortcomings in the current
- X implementation, I do not intend making any changes until I have had
- X sufficient feedback from the 'net. If you can see better ways than I
- X have outlined, for retaining the functionality whilst improving the
- X security, I will be more than pleased to hear from you. The next release
- X of QBATCH will certainly contain improvements in this area. If you want
- X to use QBATCH, and are security concious, but don't want to wait for the
- X next release, feel free to make changes as you deem fit, either those
- X outlined above, or your own (BUT please let me know what you have done).
- END_OF_FILE
- if test 4524 -ne `wc -c <'doc/chap.09'`; then
- echo shar: \"'doc/chap.09'\" unpacked with wrong size!
- fi
- # end of 'doc/chap.09'
- fi
- if test -f 'man/qbatch.l' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'man/qbatch.l'\"
- else
- echo shar: Extracting \"'man/qbatch.l'\" \(5230 characters\)
- sed "s/^X//" >'man/qbatch.l' <<'END_OF_FILE'
- X.TH QBATCH 5L "11 May 1991" QBATCH "QUEUED BATCH PROCESSING SYSTEM"
- X.SH COPYRIGHT
- The
- X.B QBATCH
- system and its related programs are:
- X.br
- Copyright (c) Vita Services Ltd. 1990
- X.br
- Copyright (c) Vita Fibres Ltd. 1991
- X.SH NAME
- X.TP 12
- X.B QBATCH
- A queued batch processing system for UNIX
- X.TP
- X.B qa
- Queue availability. List the queues the user can submit jobs to.
- X.TP
- X.B qc
- Queue create. create a batch processing queue with an optional
- processing priority, and spooling area
- X.TP
- X.B qp
- Queue process. start a process engine for a given queue
- X.TP
- X.B qh
- Queue halt. suspend processing of current job in this queue.
- X.TP
- X.B qg
- Queue go. resume processing of current job in this queue.
- X.TP
- X.B qd
- Queue disable. Prevent jobs being submitted to this queue.
- X.TP
- X.B qe
- Queue enable. Enable jobs to be submitted to this queue.
- X.TP
- X.B qs
- Queue stop. Set the stop flag for a given queue so that qp
- terminates when current job is finished.
- X(optionally to kill or repeat and kill current job)
- X.TP
- X.B qt
- Queue test. test various aspects of the queue status.
- X.TP
- X.B qw
- Queue wait. Wait until the queue process engine has terminated.
- X.TP
- X.B qf
- Queue find information. Reports (on stdout) requested information
- about the queue.
- X.TP
- X.B js
- Job submit. submit a job to an existing queue.
- X.TP
- X.B jj
- Job jump. move an entry towards the front of the queue.
- X.TP
- X.B jk
- Job kill. remove a job from this queue (optionally kill it).
- X.TP
- X.B jr
- Job repeat. repeat (optionally to kill) current job.
- X.TP
- X.B jm
- Job monitor. Add or alter monitor for a given job.
- X.TP
- X.B jn
- Job name. Add or alter name for a given job
- X.TP
- X.B rc.QBATCH
- Script (called from system boot script) to restart queues after a reboot.
- X.TP
- X.B jobdone
- This is the interface script between qp (the queue
- process engine) And the submitting user.
- On completion of a job in a queue, this script is
- called to notify the user.
- X
- X.SH SYNOPSIS
- Command synopses are provided in separate man pages for each of the above commands.
- X
- X.SH DESCRIPTION:
- X
- QBATCH was written to overcome the limitations of the UNIX at and batch
- commands where there is a need for potentially several job queues containing
- jobs to be processed in a specific order. On some versions of UNIX, it is
- possible to gain this effect by utilising the print spooling system. QBATCH
- provides a portable, consistent method of achieving this object on all
- flavours of UNIX.
- X
- The central 'tool' of QBATCH is the queue. The queue is a file, created
- in a known position in the filesystem, which contains information and
- flags used by the process subsystem, and entries relating to each job
- in the queue. There may be several such queue files, each pertaining
- perhaps to a different application or 'job stream'. Each queue is handled
- and processed separately, and may each be running it's jobs at a different
- priority (or 'nice' value). This allows background jobs to be scheduled at
- priorities relating to their importance, and their potential system load.
- X
- A job which is submitted to a queue is processed by the queue process engine,
- an activity running in the background for each queue. The jcl comprising the
- job itself is in the form of a script file in the appropriate spooling directory.
- This file contains additional jcl created by the js program which initiates
- the users jobs with the same environment, and in the same working directory
- as was applicable at the time the job was submitted. The exception to this is
- the 'fixed context queue'. A queue (which must be created by 'root') may have
- a flag set which causes the jobs running in it to ignore the submitting user's
- environment and context, and instead take it from a steering file. Access to these queues
- is controlled by the contents of the steering file.
- X.sp
- Three additional
- environment variables are created by the process engine. These are:
- X
- X.nf
- QBC A count of the number of times this job has been repeated.
- QUEUE The name of the queue in which this job is running.
- QENTRY The entry number of the job in the queue.
- X.fi
- X
- Note: Because of potential problems with some environment variables when
- running in a batch context, a mechanism is provided for excluding portions
- of the environment from this process. If a file '.qxenv' is present in the
- QUEUEPATH directory, it is interpreted as a list (one per line) of environment
- variables to be EXCLUDED from the job.
- X
- Output from jobs running in queues (stdin and stderr) are redirected to a
- monitor file. This will either be the default monitor for the queue,
- specified or defaulted when the queue was created, or one specified for a
- given job.
- X
- Script files containing the running jcl for jobs submitted to a queue are
- created in a spooling directory specified or defaulted when the queue was
- created.
- X.SH NOTE
- All
- X.B QBATCH
- programs, even when not specifically documented will return the current
- X.B QBATCH
- version number, patch level and release date if run with the -v option.
- X.SH FILES
- X.ft B
- QUEUEPATH/*
- X.SH "SEE ALSO"
- X.BR jj (1L)
- X.BR jk (1L)
- X.BR jm (1L)
- X.BR jn (1L)
- X.BR jr (1L)
- X.BR js (1L)
- X.BR qa (1L)
- X.BR qc (1L)
- X.BR qd (1L)
- X.BR qe (1L)
- X.BR qf (1L)
- X.BR qg (1L)
- X.BR qh (1L)
- X.BR ql (1L)
- X.BR qp (1L)
- X.BR qt (1L)
- X.BR qs (1L)
- X.BR qw (1L)
- X.BR rc.QBATCH (8L)
- X.BR jobdone (8L)
- X.BR queue (5L)
- X.BR qxenv (5L)
- END_OF_FILE
- if test 5230 -ne `wc -c <'man/qbatch.l'`; then
- echo shar: \"'man/qbatch.l'\" unpacked with wrong size!
- fi
- # end of 'man/qbatch.l'
- fi
- if test -f 'src/Makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/Makefile'\"
- else
- echo shar: Extracting \"'src/Makefile'\" \(4658 characters\)
- sed "s/^X//" >'src/Makefile' <<'END_OF_FILE'
- X# Makefile for QBATCH
- X#
- X# Targets are :
- X# all: Compile all programs and generate scripts
- X# install: Copy programs and scripts into $(BINDIR)
- X# inst_man: Copy nroff source man pages into $(MANDIR)
- X# make_doc: Nroff man pages into readable documents (in ../doc)
- X# clean: Remove core files, object files and programs from src.
- X# WARNING do NOT make clean before make install!
- X# shar: Repackage QBATCH as a shar kit.
- CFLAG=-g
- LDFLAG=-Bstatic
- X
- X# the directory into which to move the binaries
- BINDIR=/usr/local/bin
- X
- X# the directory into which to install the man pages
- MANDIR=/usr/man/manl
- X
- X# the bourne shell path
- SHELL=/bin/sh
- X
- X# configuration of working paths
- X# N.B. Include the quotes and the trailing '/' in the defined string
- X# both should be absolute paths (i.e leading '/'
- X
- X# first, where the queues themselves reside
- QUEUEPATH="/qbatch/"
- X
- X# where QBATCH creates it's job files and default monitors
- SPOOLPATH="/var/spool/batch/"
- X
- QPATHS=-DQUEUEPATH=\"$(QUEUEPATH)\" -DSPOOLPATH=\"$(SPOOLPATH)\"
- PROGS=jj jk jm jn jr js qa qc qd qe qf qg qh ql qp qs qt qw rc.QBATCH jobdone
- X
- all: $(PROGS)
- X @echo "\n\007programs and scripts ... make complete\n"
- X
- jj: jj.c qbatch.h config.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o -o $@
- X chmod 06711 $@
- X
- jk: jk.c qbatch.h config.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o -o $@
- X chmod 06711 $@
- X
- jm: jm.c qbatch.h config.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o -o $@
- X chmod 06711 $@
- X
- jn: jn.c qbatch.h config.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o -o $@
- X chmod 06711 $@
- X
- jr: jr.c qbatch.h config.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o -o $@
- X chmod 06711 $@
- X
- js: js.c qbatch.h config.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o -o $@
- X chmod 06711 $@
- X
- qa: qagen Makefile
- X $(SHELL) qagen $(SHELL) $(BINDIR) $(QUEUEPATH)
- X chmod 0755 $@
- X
- qc: qc.c qbatch.h config.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o -o $@
- X chmod 0700 $@
- X
- qd: qd.c qbatch.h config.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o -o $@
- X chmod 0700 $@
- X
- qe: qe.c qbatch.h config.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o -o $@
- X chmod 0700 $@
- X
- qf: qf.c qbatch.h
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c -o $@
- X chmod 0711 $@
- X
- qg: qg.c qbatch.h config.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o -o $@
- X chmod 0700 $@
- X
- qh: qh.c qbatch.h config.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o -o $@
- X chmod 0700 $@
- X
- ql: ql.c qbatch.h
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c -o $@
- X chmod 0711 $@
- X
- qp: qp.c qbatch.h config.o time.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o time.o -o $@
- X chmod 0700 $@
- X
- qs: qs.c qbatch.h config.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o -o $@
- X chmod 0700 $@
- X
- qt: qt.c qbatch.h
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c -o $@
- X chmod 06711 $@
- X
- qw: qw.c qbatch.h config.o
- X cc $(CFLAG) $(LDFLAG) $(QPATHS) $@.c config.o -o $@
- X chmod 0711 $@
- X
- jobdone: jdgen Makefile
- X $(SHELL) jdgen $(SHELL) $(BINDIR) $(QUEUEPATH)
- X chmod 0711 jobdone
- X
- rc.QBATCH: rcgen Makefile
- X $(SHELL) rcgen $(SHELL) $(BINDIR) $(QUEUEPATH)
- X chmod 0700 rc.QBATCH
- X
- config.o: config.c config.h qbatch.h
- X cc $(CFLAG) $(QPATHS) -c config.c
- X
- time.o: config.h
- X cc $(CFLAG) $(QPATHS) -c time.c
- X
- qbatch.h: what.h Makefile
- X touch qbatch.h
- X
- what.h: patchlevel.h
- X $(SHELL) < ./whatgen
- X
- install: $(BINDIR)/jj $(BINDIR)/jk $(BINDIR)/jm $(BINDIR)/jn \
- X $(BINDIR)/jr $(BINDIR)/js $(BINDIR)/qa $(BINDIR)/qc \
- X $(BINDIR)/qd $(BINDIR)/qe $(BINDIR)/qf $(BINDIR)/qg \
- X $(BINDIR)/qh $(BINDIR)/ql $(BINDIR)/qp $(BINDIR)/qs \
- X $(BINDIR)/qw $(BINDIR)/rc.QBATCH $(BINDIR)/jobdone
- X @echo "\n\007Installation of programs and scripts complete\n"
- X
- make_doc:
- X (cd ../man; \
- X $(SHELL) ./lman *.l)
- X @echo "\n\007Readable man pages conversion complete\n"
- X
- inst_man:
- X (cd ..; \
- X cp man/*.l $(MANDIR))
- X @echo "\n\007Installation of man pages complete\n"
- X
- X$(BINDIR)/rc.QBATCH: rc.QBATCH
- X cp rc.QBATCH $(BINDIR);
- X
- X$(BINDIR)/jobdone: jobdone
- X cp jobdone $(BINDIR);
- X
- X$(BINDIR)/jj: jj
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/jk: jk
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/jm: jm
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/jn: jn
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/jr: jr
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/js: js
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/qa: qa
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/qc: qc
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/qd: qd
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/qe: qe
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/qf: qf
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/qg: qg
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/qh: qh
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/ql: ql
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/qp: qp
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/qs: qs
- X cp $? $(BINDIR)
- X
- X$(BINDIR)/qw: qw
- X cp $? $(BINDIR)
- X
- shar:
- X (cd ..; \
- X rm -f qbatch.[0-9][0-9]; \
- X makekit -nqbatch. -m)
- X
- clean:
- X rm -f *.o core $(PROGS)
- END_OF_FILE
- if test 4658 -ne `wc -c <'src/Makefile'`; then
- echo shar: \"'src/Makefile'\" unpacked with wrong size!
- fi
- # end of 'src/Makefile'
- fi
- if test -f 'src/qc.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/qc.c'\"
- else
- echo shar: Extracting \"'src/qc.c'\" \(4984 characters\)
- sed "s/^X//" >'src/qc.c' <<'END_OF_FILE'
- X/************************************************************************/
- X/* */
- X/* qc .. queue create. create a batch processing queue with an optional */
- X/* processing priority, spooling area, monitor, or fixed context */
- X/* status. */
- X/* */
- X/* 0r change the priority, spooling area, monitor or fixed context */
- X/* status of a queue. */
- X/* */
- X/* usage: qc [ -m <monitor>] [-p<priority>] [-s<spoolpath>] qname */
- X/* */
- X/* Copyright (c) Vita Services 1990 */
- X/* (c) Vita Fibres 1990 1991 */
- X/* */
- X/************************************************************************/
- X
- X#include <stdlib.h>
- X#include "qbatch.h"
- int mflag, sflag = 0, pflag = 0, pval = 0, fixedcontext = 0;
- char *queuename;
- char queue [64];
- char qpath [64];
- char monitor[64];
- struct stat status;
- int fpq;
- XFILE *fp;
- main (argc, argv)
- int argc;
- char * argv[];
- X{
- X int c;
- X extern char *optarg;
- X extern int optind;
- X if (getuid() != 0)
- X {
- X fprintf (stderr, "Must be root to create a queue\n");
- X qb_term (-1);
- X }
- X while ((c = getopt (argc, argv, "fm:p:s:v")) != -1)
- X switch (c)
- X {
- X case 's':
- X strcpy (qpath, optarg);
- X sflag ++;
- X break;
- X case 'p':
- X pval = atoi (optarg);
- X pflag ++;
- X break;
- X case 'f':
- X fixedcontext ++;
- X break;
- X case 'm':
- X strcpy (monitor, optarg);
- X mflag ++;
- X break;
- X case 'v': q_version();
- X case '?': qb_term (-1);
- X }
- X if (optind >= argc)
- X {
- X fprintf (stderr, "Invalid or missing queue name!\n");
- X qb_term (-1);
- X }
- X queuename = argv[optind];
- X if (sflag)
- X {
- X if (*qpath != '/')
- X {
- X fprintf (stderr, "Relative pathspecs not permitted\n");
- X qb_exit (-1);
- X }
- X if (strlen (qpath) > 63)
- X {
- X fprintf (stderr, "Queue directory path length > 63 bytes\n");
- X qb_term (-1);
- X }
- X }
- X else strcpy (qpath, SPOOLPATH);
- X if ((monitor[0] != 0) && (strcmp (monitor, "NONE")) != 0)
- X {
- X if (strlen (monitor) > 63)
- X {
- X fprintf (stderr, "Monitor path length > 63 bytes\n");
- X qb_term (-1);
- X }
- X if (*monitor != '/')
- X {
- X fprintf (stderr, "Relative pathspecs not permitted\n");
- X qb_exit (-1);
- X }
- X if (access(monitor, W_OK) == 0) /* monitor path is accessible */
- X {
- X fp = fopen (monitor, "w");
- X if (fp == NULL) /* monitor is a directory */
- X {
- X if (monitor [strlen(monitor) - 1] != '/')
- X strcat (monitor, "/");
- X strcat (monitor, queuename);
- X strcat (monitor, ".mon");
- X }
- X else fclose (fp);
- X }
- X else /* file does not exist or we don't have access */
- X {
- X fp = fopen (monitor, "w"); /*can we create it? */
- X if (fp == NULL)
- X {
- X fprintf (stderr, "Invalid path for monitor: %s\n", monitor);
- X qb_term (-1);
- X }
- X else
- X {
- X fclose (fp);
- X unlink (monitor);
- X }
- X }
- X }
- X else
- X {
- X if (strcmp (monitor, "NONE") != 0)
- X {
- X strcpy (monitor, qpath);
- X if (monitor[strlen(monitor) -1] != '/') strcat (monitor, "/");
- X strcat (monitor, queuename);
- X strcat (monitor, ".mon");
- X }
- X }
- X strcpy (queue, QUEUEPATH);
- X strcat (queue, queuename);
- X qb_setterm();
- X if (access(queue, F_OK))
- X {
- X strcpy (head.q_magic, "qBq");
- X head.qh_pid = 0;
- X head.qh_noentries = 0;
- X head.qh_hiwater = 0;
- X head.qh_priority = 0;
- X head.qh_flags = (unsigned int) qh_enabled;
- X head.qh_proc = 0;
- X head.qh_start = 0;
- X head.qh_queued = 0;
- X head.qh_real = 0;
- X head.qh_user = 0;
- X head.qh_system = 0;
- X head.qh_jobcount = 0;
- X sflag = mflag = 1;
- X fpq = open (queue, O_RDWR+O_CREAT, 0644);
- X if (fpq == -1)
- X {
- X fprintf (stderr, "cannot create queue\n");
- X qb_term (-1);
- X }
- X q_lock(fpq);
- X }
- X else
- X {
- X fpq = open (queue, O_RDWR);
- X if (fpq == -1)
- X {
- X fprintf (stderr, "cannot open queue\n");
- X qb_term (-1);
- X }
- X q_lock(fpq);
- X lseek (fpq, 0, SEEK_SET);
- X read (fpq, &head, sizeof(head));
- X if (bad_queue()) qb_exit(-1);
- X }
- X if (sflag) strcpy (head.qh_spool, qpath);
- X if (mflag) strcpy (head.qh_defmon, monitor);
- X if (pflag) head.qh_priority = pval;
- X if (fixedcontext)
- X {
- X if ((head.qh_flags & qh_fixed) == 0)
- X head.qh_flags += (unsigned int) qh_fixed;
- X else head.qh_flags -= (unsigned int) qh_fixed;
- X }
- X lseek (fpq, 0, SEEK_SET);
- X write (fpq, &head, sizeof(head));
- X qb_term (0);
- X}
- END_OF_FILE
- if test 4984 -ne `wc -c <'src/qc.c'`; then
- echo shar: \"'src/qc.c'\" unpacked with wrong size!
- fi
- # end of 'src/qc.c'
- fi
- if test -f 'src/ql.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/ql.c'\"
- else
- echo shar: Extracting \"'src/ql.c'\" \(4918 characters\)
- sed "s/^X//" >'src/ql.c' <<'END_OF_FILE'
- X/************************************************************************/
- X/* */
- X/* ql .. queue list .. list the contents of a queue */
- X/* */
- X/* usage: ql [-a] qname */
- X/* */
- X/* Copyright (c) Vita Services 1990 */
- X/* (c) Vita Fibres 1990 1991 */
- X/* */
- X/************************************************************************/
- X
- X#include "qbatch.h"
- X#include <time.h>
- XFILE *fpq;
- char buff[128];
- char started[7], repeated[3], killed[3], enabled[3], stopped[3], halted[3];
- char Yes[] = "Yes";
- char No[] = "No";
- struct tm *jtimes;
- char *queuename;
- int i, aflag;
- void q_version()
- X{
- X puts (&QbSID[5]);
- X puts ("");
- X puts (&QbCR1[5]);
- X puts (&QbCR2[5]);
- X puts ("");
- X exit(0);
- X}
- int bad_queue()
- X{
- X if (strcmp (head.q_magic, "qBq") != 0)
- X {
- X fprintf(stderr,"%s is not a valid QBATCH queue\007\n", queuename);
- X return(-1);
- X }
- X return(0);
- X}
- main (argc,argv)
- int argc;
- char *argv[];
- X{
- X int c;
- X extern char *optarg;
- X extern int optind;
- X if (argc == 1)
- X {
- X puts ("Usage ql [-a] <qname>");
- X exit (0);
- X }
- X while ((c = getopt (argc, argv, "av")) != -1)
- X switch (c)
- X {
- X case 'a': aflag ++;
- X break;
- X case 'v': q_version();
- X case '?': exit (-1);
- X }
- X if (optind >= argc)
- X {
- X fprintf (stderr, "Invalid or missing queue name!\n");
- X exit (-1);
- X }
- X queuename = argv[optind];
- X strcpy (buff, QUEUEPATH);
- X strcat (buff, queuename);
- X fpq = fopen (buff, "r");
- X if (fpq == NULL)
- X {
- X fprintf (stderr, "Invalid queue name: %s!\n",queuename);
- X exit (-1);
- X }
- X fread (&head, sizeof(head), 1, fpq);
- X if (bad_queue())
- X {
- X fclose (fpq);
- X exit(-1);
- X }
- X if (head.qh_pid) sprintf (started, "%d", head.qh_pid);
- X else strcpy (started, " No");
- X printf ("Status of : %s %s\n", queuename,
- X (head.qh_flags&qh_fixed) ? "(fixed context)":"");
- X printf ("Spooling in : %s\n", head.qh_spool);
- X printf ("Monitor is : %s\n", head.qh_defmon);
- X printf ("Priority is : %d\n", head.qh_priority);
- X if (head.qh_proc != 0)
- X {
- X jtimes = localtime(&head.qh_proc);
- X printf ("Queue last started : %2d/%02d/%02d %2d:%02d:%02d\n",
- X jtimes->tm_mday, jtimes->tm_mon+1, jtimes->tm_year,
- X jtimes->tm_hour, jtimes->tm_min, jtimes->tm_sec);
- X }
- X else printf ("Queue not running\n");
- X if (head.qh_start != 0)
- X {
- X jtimes = localtime(&head.qh_start);
- X printf ("Current job started : %2d/%02d/%02d %2d:%02d:%02d\n",
- X jtimes->tm_mday, jtimes->tm_mon+1, jtimes->tm_year,
- X jtimes->tm_hour, jtimes->tm_min, jtimes->tm_sec);
- X }
- X else printf ("Queue is idle\n");
- X printf ("\n No of Active Queue Job Job Queue Queue\n");
- X printf (" Entries (pid) Accepting Repeated Killed Halted Stopped\n");
- X printf (" %5d",head.qh_noentries);
- X printf (" %-5s", started);
- X if (head.qh_flags&qh_enabled) printf (" Yes");
- X else printf (" No ");
- X if (head.qh_flags&qh_repeat) printf (" Yes");
- X else printf (" No ");
- X if (head.qh_flags&qh_kill) printf (" Yes");
- X else printf (" No ");
- X if (head.qh_flags&qh_halt) printf (" Yes");
- X else printf (" No ");
- X if (head.qh_flags&qh_stop) printf (" Yes\n\n");
- X else printf (" No\n\n");
- X for (i = 0; i< head.qh_noentries;i++)
- X {
- X fread (&entry, sizeof(entry), 1, fpq);
- X printf ("%3d ", entry.qe_jobno);
- X if (entry.qe_status) printf ("%5d ",entry.qe_status);
- X else printf (" ");
- X printf ("%-10s ", entry.qe_uname);
- X printf ("%-8s ", entry.qe_tty);
- X jtimes = localtime(&entry.qe_submitted);
- X printf ("%2d/%02d/%02d %2d:%02d:%02d ",
- X jtimes->tm_mday, jtimes->tm_mon+1, jtimes->tm_year,
- X jtimes->tm_hour, jtimes->tm_min, jtimes->tm_sec);
- X printf ("%s\n", entry.qe_jobname);
- X if (aflag)
- X {
- X printf ("uid: %d, gid: %d, jcl: %s\n",entry.qe_uid, entry.qe_gid, entry.qe_jcl);
- X if (entry.qe_monitor[0] == 0) printf ("Monitor : default\n\n");
- X else printf ("Monitor : %s\n\n", entry.qe_monitor);
- X }
- X }
- X printf ("\n");
- X fclose (fpq);
- X exit (0);
- X}
- END_OF_FILE
- if test 4918 -ne `wc -c <'src/ql.c'`; then
- echo shar: \"'src/ql.c'\" unpacked with wrong size!
- fi
- # end of 'src/ql.c'
- fi
- echo shar: End of archive 3 \(of 6\).
- cp /dev/null ark3isdone
- MISSING=""
- for I in 1 2 3 4 5 6 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 6 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-